package com.dog.basics.admin.controller.mtkj;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.mtkj.HospitalWheelchairAddDto;
import com.dog.basics.bean.dto.admin.mtkj.HospitalWheelchairEditDto;
import com.dog.basics.bean.dto.admin.mtkj.HospitalWheelchairFromDto;
import com.dog.basics.bean.vo.admin.mtkj.HospitalWheelchairVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.mtkj.IMtDeviceHospitalWheelchairService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;

/**
 * <p>
 * 医院轮椅关联 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-09-29
 */
@RestController
@RequestMapping("/pc/device/hospital/wheelchair")
@Api(value = "医院轮椅关联模块", tags = "医院轮椅关联模块")
@AllArgsConstructor
public class MtDeviceHospitalWheelchairController {
    private final IMtDeviceHospitalWheelchairService mtDeviceHospitalWheelchairService;

    /**
     * @Description: 医院轮椅关联列表
     * @Param: HospitalWheelchairFromDto
     * @return: IPage<HospitalWheelchairVo>
     * @Author: wph
     * @Date:
     */

    @ApiOperation(value = "医院轮椅关联列表", notes = "pc:mtDeviceHospitalWheelchair:page")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceHospitalWheelchair:page')")
    @ApiIgnore
    public R<IPage<HospitalWheelchairVo>> page(PageParam page, HospitalWheelchairFromDto obj) {
        IPage<HospitalWheelchairVo> list = mtDeviceHospitalWheelchairService.getPageList(page, obj);
        return R.ok(list);
    }

    /**
     * @Description: 增加医院轮椅关联
     * @Param: HospitalWheelchairAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("增加医院轮椅关联")
    @ApiOperation(value = "增加医院轮椅关联", notes = "pc:mtDeviceHospitalWheelchair:save")
    @PostMapping("/save")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceHospitalWheelchair:save')")
    public R<Boolean> save(@Valid @RequestBody HospitalWheelchairAddDto obj) {
        return R.ok(mtDeviceHospitalWheelchairService.saveObj(obj));
    }

    /**
     * @Description: 删除医院轮椅关联
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("删除医院轮椅关联")
    @ApiOperation(value = "删除医院轮椅关联", notes = "pc:mtDeviceHospitalWheelchair:delete")
    @ApiImplicitParam(value = "轮椅Id", name = "id", dataType = "Long", required = true)
    @DeleteMapping("/delete/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceHospitalWheelchair:delete')")
    public R<Boolean> delete(@PathVariable("id") Long id) {
        return R.ok(mtDeviceHospitalWheelchairService.deleteObj(id));
    }

    /**
     * @Description: 修改医院轮椅关联
     * @Param: HospitalWheelchairEditDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("修改医院轮椅关联")
    @ApiOperation(value = "修改医院轮椅关联", notes = "pc:mtDeviceHospitalWheelchair:edit")
    @PutMapping("/edit")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceHospitalWheelchair:edit')")
    @ApiIgnore
    public R<Boolean> edit(@Valid @RequestBody HospitalWheelchairEditDto obj) {
        return R.ok(mtDeviceHospitalWheelchairService.editObj(obj));
    }
}
